<?php

declare (strict_types=1);
namespace App\Model;

/**
 * @property int $id
 * @property string $name
 * @property string $cover
 * @property string $eva_id
 * @property int $hot
 * @property int $sort
 * @property int $charge
 * @property string $recommend_type
 * @property string $lang
 * @property string $status
 */
class PsychologicalAssessment extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'psychological_assessment';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $guarded = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'hot' => 'integer', 'sort' => 'integer', 'charge' => 'integer'];

    public static function getEvaluatingList()
    {
        $lang = getLang();
        $model = PsychologicalAssessment::where(['status'=>1,'lang'=>$lang])->orderBy('hot','desc')->orderBy('sort','desc');

        return page($model);
    }

    /**
     * 搜索评测
     * @param $keyword
     * @return array
     */
    public static function searchEvaluatingList($keyword)
    {
        $where[] =['status','=',1];
        $where[] =['name','like',"%$keyword%"];//评测名字

        $model = PsychologicalAssessment::where($where)->orderBy('hot','desc')->orderBy('sort','desc');

        return page($model);

    }
}
